import Layout from '@/views/layout/Layout'

/**
 * 404
 */
export const page404 = {
  path: '*',
  name: '404',
  meta: {
    title: '404-您访问的页面不存在'
  },
  component: resolve => {
    require(['@/views/error/404'], resolve)
  }
}

/**
 * 登录注册
 */
export const loginRouter = [{
  path: '/login',
  name: 'Login',
  meta: {
    title: '登录'
  },
  component: resolve => {
    require(['@/views/login/Index'], resolve)
  }
}]

/**
 * 首页路由
 */
export const appRouter = [{
  path: '/',
  redirect: '/index',
  name: 'Layout',
  meta: {
    title: 'nicemusic'
  },
  component: Layout,
  children: [
    {
      path: '/index',
      meta: {
        title: '首页'
      },
      name: 'Home',
      component: resolve => {
        require(['@/views/home/Home'], resolve)
      }
    },
    {
      path: '/recommend',
      meta: {
        title: '每日推荐'
      },
      name: 'Recommend',
      component: resolve => {
        require(['@/views/recommend/Index'], resolve)
      }
    },
    {
      path: '/songlist',
      meta: {
        title: '歌单广场'
      },
      name: 'Songlist',
      component: resolve => {
        require(['@/views/songlist/Index'], resolve)
      }
    },
    {
      path: '/songlistDetail',
      meta: {
        title: '歌单'
      },
      name: 'SonglistDetail',
      component: resolve => {
        require(['@/views/songlistDetail/Index'], resolve)
      }
    },
    {
      path: '/videolist',
      meta: {
        title: '视频广场'
      },
      name: 'Videolist',
      component: resolve => {
        require(['@/views/videolist/Index'], resolve)
      }
    },
    {
      path: '/ranklist',
      meta: {
        title: '排行榜'
      },
      name: 'Ranklist',
      component: resolve => {
        require(['@/views/ranklist/Index'], resolve)
      }
    },
    {
      path: '/singer',
      meta: {
        title: '歌手分类'
      },
      name: 'Singer',
      component: resolve => {
        require(['@/views/singer/Index'], resolve)
      }
    }
  ]
}]

export const routes = [
  page404,
  ...loginRouter,
  ...appRouter
]
